﻿<Page
    x:Class="MarginCalc.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MarginCalc"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conv="using:MarginCalc.Converters"
    mc:Ignorable="d" DataContext="{StaticResource MainViewModel}">
    <Page.Resources>
        <conv:CurrencyConverter x:Key="dc"/>
        <conv:PercentConverter x:Key="pc" />
    </Page.Resources>
    <StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="Margin calculator" FontSize="45" Margin="10" />
        </StackPanel>
        <Grid>
            <TextBlock HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="%Tax" />
            <TextBox Margin="10,22,10,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding TaxPercent,Mode=TwoWay,Converter={StaticResource pc}}"/>
            <TextBlock HorizontalAlignment="Left" Margin="10,59,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="Cost" />
            <TextBox Margin="10,72,140,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding Cost,Mode=TwoWay,Converter={StaticResource dc}}"/>
            <Button Content="Calculate" HorizontalAlignment="Right" Margin="0,72,10,0" VerticalAlignment="Top" Width="125" Command="{Binding CalculateCostCommand}"/>
            <TextBlock HorizontalAlignment="Left" Margin="10,109,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="%Margin" />
            <TextBox Margin="10,122,140,0" TextWrapping="Wrap" Text="{Binding MarginPercent,Mode=TwoWay,Converter={StaticResource pc}}" VerticalAlignment="Top"/>
            <Button Content="Calculate" HorizontalAlignment="Right" Margin="0,122,10,0" VerticalAlignment="Top" Width="125" Command="{Binding CalculateMarginPercentCommand}"/>
            <TextBlock HorizontalAlignment="Left" Margin="10,159,0,0" TextWrapping="Wrap" Text="Final price" VerticalAlignment="Top"/>
            <TextBox Margin="10,172,140,0" TextWrapping="Wrap" Text="{Binding FinalPrice,Mode=TwoWay,Converter={StaticResource dc}}" VerticalAlignment="Top"/>
            <Button Content="Calculate" HorizontalAlignment="Right" Margin="0,172,10,0" VerticalAlignment="Top" Width="125" Command="{Binding CalculateFinalPriceCommand}"/>
        </Grid>
    </StackPanel>
</Page>
